<%@tag import="java.util.List"%>
<%@tag import="com.pengtu.gsj.utils.spring.AttachmentUtils"%>
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ attribute name="partId" type="java.lang.String" required="true" description="上传附件的某项目的Id" %>
<%@ attribute name="tableId" type="java.lang.String" required="true" description="附件的某个表ID"%>
<%@ attribute name="tableName" type="java.lang.String" required="true" description="表的名称"%>
<%@ attribute name="tableField" type="java.lang.String" required="true" description="某个区域"%>
<%@ attribute name="labelName" type="java.lang.String" required="true" description="附件显示名称"%>
<%@ attribute name="viewOnly" type="java.lang.String" required="false" description="是否继续上传"%>
<%@ attribute name="viewOnly2" type="java.lang.String" required="false" description="是否继续上传1"%>
<% List attacs= AttachmentUtils.getAttachments(tableId,tableField) ;
   jspContext.setAttribute("attacs",attacs);
%>
<c:if test="${!empty attacs}">
	<div class="dropdown clearfix"  id="dropdown_${tableId}${tableField}">
		<ul class="dropdown-menu" id="menu2_${tableId}${partId}"
			role="menu" aria-labelledby="dropdownMenu"
			style="display: block; position: static; margin-bottom: 5px; *width: 230px;">
			<c:forEach items="${attacs}" var="att" varStatus="stai">
				<li role='presentation' class='attac'>
					<p class='attName'>
						<i class='i_group i_${att.fileIcon}_h17'></i> <a role='menuitem'
							style='text-decoration: underline;' tabindex='-1'
							href='${ctx}${att.urlPath}' target='_blank' title='${att.name}'>${att.name}</a>(${att.uploadPerson};
						<fmt:formatDate value="${att.createDate}" pattern="yyyy-MM-dd" />)
					</p>
				</li>
			</c:forEach>
			<li class="divider" id="divider_${tableId}${tableField}"></li>
			<li role="presentation"><p class='attName'>
			<c:if test="${!viewOnly}"><a role="menuitem" tabindex="-1" onclick='uploadAttachmentFile("${tableId}","${tableName}","${partId}","${tableField}","${labelName}")'
					href="javascript:void(0);" title="${labelName}附件继续上传">继续上传<i class='icon-arrow-up'></i></a>
			</c:if>		
					(${labelName})</p>
				</li>
		</ul>
	</div>
<button class="btn btn-success dropdown-toggle" style="display: none;" id="button_${tableId}${tableField}" onclick='uploadAttachmentFile("${tableId}","${tableName}","${partId}","${tableField}","${labelName}")' data-toggle="dropdown">${labelName}附件<span class="caret"></span></button>
</c:if>
<c:if test="${empty attacs}">
<c:if test="${!viewOnly}">
  <div class="dropdown clearfix" style="display: none;" id="dropdown_${tableId}${tableField}">
              <ul class="dropdown-menu" id="menu2_${tableId}${tableField}" role="menu" aria-labelledby="dropdownMenu" style="display: block; position: static; margin-bottom: 5px; *width: 230px;">
				  <li class="divider" id="divider_${tableId}${tableField}"></li>
				  <li role="presentation"><p class='attName'><a role="menuitem" tabindex="-1" onclick='uploadAttachmentFile("${tableId}","${tableName}","${partId}","${tableField}","${labelName}")'
					href="javascript:void(0);"  title="${labelName}附件继续上传">继续上传<i class='icon-arrow-up'></i></a>(${labelName})</p>
				</li>
              </ul>
    </div>
	<button class="btn btn-success " type="button" id="button_${tableId}${tableField}" onclick='uploadAttachmentFile("${tableId}","${tableName}","${partId}","${tableField}","${labelName}")' data-toggle="dropdown">${labelName}附件<i class='icon-arrow-up'></i></button>
</c:if>
<c:if test="${viewOnly}">
	  <div class="dropdown clearfix"  id="dropdown_${tableId}${tableField}">
              <ul class="dropdown-menu" id="menu2_${tableId}${tableField}" role="menu" aria-labelledby="dropdownMenu" style="display: block; position: static; margin-bottom: 5px; *width: 230px;">
				  <li role="presentation"><p class='attName'>${labelName}未上传附件...</p>
				</li>
              </ul>
       </div>
</c:if>
</c:if>